package com.hmall.common.client;

import com.hmall.common.pojo.Item;
import com.hmall.common.response.PageResultVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @description:
 * @Date: 2023/4/9 11:53
 */
@FeignClient("itemservice")
public interface ItemClient {
    /**
     * 分页查询
     *
     * @param currentPage
     * @param size
     * @return
     */
    @GetMapping("/item/list")
    PageResultVO<Item> page(@RequestParam("page") Integer currentPage, @RequestParam("size") Integer size);

    /**
     * 根据id查商品
     *
     * @param id
     * @return
     */
    @PutMapping("/item/{id}")
    Item getItem(@PathVariable Long id);


    @GetMapping("/item/{id}")
    Item findById(@PathVariable("id") Long id);

    @GetMapping("/item/stock/{id}/{num}")
    void reduceStock(@PathVariable("id") Long id,
                     @PathVariable("num") Integer num);

    @GetMapping("/item/returnStock/{id}/{num}")
    int returnStock(@PathVariable("id") Long id,
                    @PathVariable("num") Integer num);
}
